package test2.spider.news.cnfol;

import org.apache.commons.collections.CollectionUtils;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import test2.spider.BaseProcessor;
import test2.spider.ThreadLocalUtil;

public class DetailPageProcessor extends BaseProcessor {

	@Override
	protected void parse(Document doc) {
		Element root = doc.select(".NewArt").get(0);
		String content = root.select("#Content").get(0).text();
		Elements page = root.select("#page");
		if(CollectionUtils.isNotEmpty(page)) {
			Elements next = page.select("#pagenav_next");
			if(CollectionUtils.isNotEmpty(next)) {
				String href = next.get(0).attr("href");
				ThreadLocalUtil.put("content", ThreadLocalUtil.get("content") + content);
				new DetailPageProcessor().process(href);
			}
			
		}
	}

}
